package com.firexxx.detect.util;

public class CurlUtil {

    /*
        文档介绍：https://curl.se/docs/manpage.html
        time_namelookup:  dns耗时
        time_connect:  time_namelookup + 三次握手
        time_appconnect:  连接建立完成时间
        time_pretransfer:  从开始到准备传输的时间
        time_redirect:  0.000 s
        time_starttransfer:  开始到接收到服务端第一个字节耗时
        time_total:  请求总耗时
     */
    public static String getCommand(String url) {
        return "curl -w \"\\nurl_effective:  %{url_effective}\\nhttp_code:  %{http_code}\\nsize_download:  %{size_download} bytes\\nsize_upload:  %{size_upload} bytes\\nsize_request:  %{size_request} bytes\\nspeed_download:  %{speed_download} byte/s\\nspeed_upload:  %{speed_upload} byte/s\\ncontent_type:  %{content_type}\\nssl_verify_result:  %{ssl_verify_result}\\n\\ntime_namelookup:  %{time_namelookup} s\\ntime_connect:  %{time_connect} s\\ntime_appconnect:  %{time_appconnect} s\\ntime_pretransfer:  %{time_pretransfer} s\\ntime_redirect:  %{time_redirect} s\\ntime_starttransfer:  %{time_starttransfer} s\\n----------\\ntime_total:  %{time_total} s\\n\\n\" -o /dev/null -s " + url;
    }

    public static void main(String[] args) {
        System.out.println(CurlUtil.getCommand("http://www.baidu.com"));
    }

}
